home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / bin / makeqtmake.z / makeqtmake
Encoding:
Text File  |  1998-10-28  |  2.8 KB  |  124 lines

  1. #!/usr/bin/perl
  2. ############################################################################
  3. # $Id: makeqtmake,v 1.4 1998/02/27 14:00:41 hanord Exp $
  4. #
  5. # Makes Qt makefiles and a project file - internal Troll Tech tool.
  6. #
  7. # Usage:
  8. #    makeqtmake [-lib] [-cvs] [-nopro] projectname
  9. #
  10. # Copyright (C) 1998 by Troll Tech AS.  All rights reserved.
  11. #
  12. ############################################################################
  13.  
  14. $libtarget = "";
  15. $project = "";
  16. $cvs = 0;
  17. $nopro = 0;
  18.  
  19. while ( @ARGV ) {                # parse command line args
  20.     $_ = shift @ARGV;
  21.     if ( s/^-// ) {
  22.     if ( $_ eq "app" ) {
  23.         $libtarget = "";
  24.     } elsif ( $_ eq "cvs" ) {
  25.         $cvs = 1;
  26.     } elsif ( $_ eq "lib" ) {
  27.         $libtarget = "LIBTARGET = 1\n";
  28.     } elsif ( $_ eq "nopro" ) {
  29.         $nopro = 1;
  30.     } else {
  31.         die "Invalid option";
  32.     }
  33.     } else {
  34.     $project = $_;
  35.     }
  36. }
  37.  
  38. $project || die "No project name specified";
  39.  
  40. $win32make =
  41. "#############################################################################
  42. # \$" .
  43. "Id: makeqtmake,v 1.3 1996/01/22 13:46:00 hanord Exp " .
  44. "\$
  45. #
  46. # Win32 Makefile, requires Microsoft nmake.
  47. #
  48. # Copyright (C) 1998 by Troll Tech AS.  All rights reserved.
  49. #
  50. #############################################################################
  51.  
  52. PROJECT = $project
  53. $libtarget
  54. !INCLUDE \$(QTDIR)\\Makefile.inc
  55. ";
  56.  
  57. $unixmake =
  58. "#############################################################################
  59. # \$" .
  60. "Id: makeqtmake,v 1.3 1996/01/22 13:46:00 hanord Exp " .
  61. "\$
  62. #
  63. # Unix Makefile, requires GNU make (gmake).
  64. #
  65. # Copyright (C) 1998 by Troll Tech AS.  All rights reserved.
  66. #
  67. #############################################################################
  68.  
  69. PROJECT = $project
  70. $libtarget
  71. include \$(QTDIR)/GNUmakefile.inc
  72. ";
  73.  
  74. if ( open( F, "> Makefile" ) ) {
  75.     print F $win32make;
  76.     close F;
  77. }
  78. if ( open( F, "> GNUmakefile" ) ) {
  79.     print F $unixmake;
  80.     close F;
  81. }
  82. $libtarget && ($libtarget = "-t lib");
  83. if ( ! $nopro ) {
  84.     $files = join(" ",find_files(".",'\.(h|cpp)$',0));
  85.     `progen -n $project $libtarget -o $project.pro $files`;
  86. }
  87. $cvs && `cvs add $project.pro Makefile GNUmakefile`;
  88. exit 0;
  89.  
  90.  
  91.  
  92. #
  93. # Finds files.
  94. #
  95. # Examples:
  96. #   find_files("/usr","\.cpp$",1)   - finds .cpp files in /usr and below
  97. #   find_files("/tmp","^#",0)        - finds #* files in /tmp
  98. #
  99.  
  100. sub find_files {
  101.     my($dir,$match,$descend) = @_;
  102.     my($file,$p,@files);
  103.     local(*D);
  104.     $dir =~ s=\\=/=g;
  105.     ($dir eq "") && ($dir = ".");
  106.     if ( opendir(D,$dir) ) {
  107.     if ( $dir eq "." ) {
  108.         $dir = "";
  109.     } else {
  110.         ($dir =~ /\/$/) || ($dir .= "/");
  111.     }
  112.     foreach $file ( readdir(D) ) {
  113.         next if ( $file  =~ /^\.\.?$/ );
  114.         $p = $dir . $file;
  115.         ($file =~ /$match/) && (push @files, $p);
  116.         if ( $descend && -d $p && ! -l $p ) {
  117.         push @files, &find_files($p,$match,$descend);
  118.         }
  119.     }
  120.     closedir(D);
  121.     }
  122.     return @files;
  123. }
  124.